package sctu.edu.java.year2016.team06.luoxin.day20160607.chapter15_1;

/**尝试定义一个继承Thread类的类，并覆盖run()方法，在run（）方法中每隔100毫秒打印一句话。p378
 * Created by Administrator on 2016/6/7.
 */
public class InheritThread  extends  Thread{
    private Thread t;
    private boolean isContinue=false;                   //设置一个标记变量，默认值为false
    public void run(){                                 //重写run()方法
        while(true){

                try {
                    t.sleep((long) 0.1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }finally{
                    System.out.println("today is fully!");
            }
            if(isContinue)                    //当isComtinue变量为true时，停止线程
            break;
        }
    }
    public void setContinue(){               //定义设置isContinue变量为true的方法
        this.isContinue=true;
    }

    public static void main(String[] args)
    {
        new Thread (new InheritThread()).start();
    }
}
